package com.csust.automaticteach.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csust.automaticteach.model.entity.Exercises;
import com.csust.automaticteach.model.entity.SetExercises;
import com.csust.automaticteach.service.SetExercisesService;
import com.csust.automaticteach.mapper.SetExercisesMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 钰玟
* @description 针对表【t_set_exercises(套题-题目关联表)】的数据库操作Service实现
* @createDate 2025-07-23 20:16:43
*/
@Service
public class SetExercisesServiceImpl extends ServiceImpl<SetExercisesMapper, SetExercises>
    implements SetExercisesService{

    @Override
    public List<SetExercises> getSetExercisesList(List<Exercises> exercisesList, Long setId) {
        List<SetExercises> setExercisesList = new ArrayList<>();
        for (int i = 0; i < exercisesList.size(); i++) {
            Exercises ex = exercisesList.get(i);
            SetExercises setExercises = SetExercises.builder()
                    .exerciseId(ex.getId())
                    .setId(setId)
                    .position(i)
                    .build();
            setExercisesList.add(setExercises);
        }
        return setExercisesList;
    }
}




